package com.mybts.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybts.model.User;
import com.mybts.mapper.UserMapper;
import com.mybts.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mybts.util.Paging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhipeng
 * @since 2019-07-27
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Page<User> pageUser(Paging page, User userPO) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
        Page<User> page1 = new Page<User>(page.getPageNum(),page.getPageSize());
        List<User> users = userMapper.selectList(queryWrapper);
        page1.setRecords(users);

        return page1;
    }

    @Override
    public Boolean addUser(User user) {

        userMapper.insert(user);

        return true;
    }

    @Override
    public Boolean updateUser(User user) {

        userMapper.updateById(user);


        return true;
    }

    @Override
    public Boolean delUser(User user) {

        userMapper.deleteById(user);
        return true;
    }
}
